PROJECT (XTL_UNITTESTS)

SET (TESTCASE_H cppunit/TestCase.h)

FIND_PATH (
	CPPUNIT_INCLUDE_DIR
	${TESTCASE_H}
	PATH
		/usr/local/include
		/usr/include
		NO_DEFAULT_PATH
	DOC
		"Searching ${TESTCASE_H}"
)

# FIND_PATH (
# 	CPPUNIT_INCLUDE_DIR ${TESTCASE_H}
# )

FIND_LIBRARY (
	CPPUNIT_LIBRARY
	NAMES
		cppunit
		libcppunit
	PATH
		/usr/local/lib
		/usr/lib
		NO_DEFAULT_PATH
	DOC
		"Searching cppunit library"
)

FIND_LIBRARY (
	CPPUNIT_LIBRARY
	NAMES
		cppunit
		libcppunit
)

IF (CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY)
	SET (CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY}) # ${Dl_LIBRARY}
	SET (CPPUNIT_FOUND TRUE)
ELSE (CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY)
	SET (CPPUNIT_FOUND FALSE)
ENDIF (CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY)

IF (CPPUNIT_FOUND)
	MESSAGE (STATUS "cppunit found")
ELSE (CPPUNIT_FOUND)
	MESSAGE (FATAL_ERROR "Required package cppunit NOT found")
ENDIF (CPPUNIT_FOUND)

MARK_AS_ADVANCED (
	CPPUNIT_INCLUDE_DIR
	CPPUNIT_LIBRARIES
)

INCLUDE_DIRECTORIES (
#	../lib
	${CPPUNIT_INCLUDE_DIR}
)

#    PARSE_ARGUMENTS(TEST "SOURCES;LIBRARIES" "" ${ARGN})

#    CAR(TEST_NAME ${TEST_DEFAULT_ARGS})

#    ADD_EXECUTABLE(${TEST_NAME} ${CMAKE_SOURCE_DIR}/unittests/main.cpp ${TEST_SOURCES})
#    TARGET_LINK_LIBRARIES(${TEST_NAME} ${TEST_LIBRARIES} ${CPPUNIT_LIBRARIES})

#    SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES
#        COMPILE_FLAGS "-DSTANDARD_DATA=\\\"${CMAKE_SOURCE_DIR}/unittests/standard_data/\\\""
#        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/unittests/bin")

#    ADD_TEST(${TEST_NAME} ${EXECUTABLE_OUTPUT_PATH}/${TEST_NAME})


# CPPUNIT_ADD_TEST(elempool_utest SOURCES ElemPoolTest.cpp)

ADD_EXECUTABLE (
	xtl_unittests
		main.cpp
		Base64Test.cpp
		BitSetTest.cpp
		DateTest.cpp
		FormatStringTest.cpp
		SimpleTemplateTest.cpp
		StringSplitterTest.cpp
		StringUtilsTest.cpp
)

TARGET_LINK_LIBRARIES (
	xtl_unittests
		${CPPUNIT_LIBRARIES}
		dl
		xtl
)

